﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AIMLbot;
using BlackBoard;
namespace Yeti_v0._01
{
    public partial class Main : Page
    {
        private string txt, empty = "";
        private Bot yeti = new Bot();
        private User user;
        private Request request;
        private Result result;
        private BlackBoard.BlackBoard blackBoard;
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox2.Focus();
            yeti.loadSettings(System.IO.Path.Combine(Server.MapPath(""), System.IO.Path.Combine("config", "Settings.xml")));
           // yeti.loadSettings(@"C:\Users\hcymerys\Documents\Users\hcymerys\huberta dokumenty\Inzynierka\Settings.xml");
            yeti.loadAIMLFromFiles();
            user = new User("usr", yeti);
            blackBoard = new BlackBoard.BlackBoard();
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            txt = TextBox2.Text;
            TextBox2.Text = empty;
            TextBox1.Text += "<user> " + txt + Environment.NewLine;
            var asd = blackBoard.PrintLastOne(txt);
            request = new Request(blackBoard.PrintLastOne(txt), user, yeti);
            result = yeti.Chat(request);
            TextBox1.Text += "<yeti> " + result.Output + Environment.NewLine;
        }

        protected void Button2_Click1(object sender, EventArgs e)
        {
            txt = TextBox2.Text;
            TextBox2.Text = empty;
            TextBox1.Text += "<user> " + txt + Environment.NewLine;
            foreach (var t in blackBoard.PrintAll(txt))
            {
                TextBox1.Text += t + Environment.NewLine;
            }

            request = new Request(blackBoard.PrintLastOne(txt), user, yeti);
            result = yeti.Chat(request);
            TextBox1.Text += "<yeti> " + result.Output + Environment.NewLine;
        }
    }
}